package com.itheima.kafka.example2;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * 示例2：监听 Stream 处理结果
 * 
 * 学习目标：
 * 1. 查看 Stream 处理后的结果
 * 2. 理解 Stream 的输出
 */
@Slf4j
@Component
public class StreamResultListener {

    /**
     * 监听单词计数的结果
     */
    @KafkaListener(topics = "word-count-output", groupId = "result-group")
    public void listenResult(ConsumerRecord<String, String> record) {
        log.info("═══════════════════════════════════════");
        log.info("✨ [结果监听器] Stream处理结果：");
        log.info("✨ 单词: {}", record.key());
        log.info("✨ 统计: {}", record.value());
        log.info("═══════════════════════════════════════");
    }
}

